-
Notifications
You must be signed in to change notification settings - Fork 20
feat: add Anthropic Claude message format helpers, fix some types and change names #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add support for Anthropic Claude-style messages as input and output: Input formats now supported: - OpenResponses format (native) - OpenAI Chat Completions format (Message[]) - Anthropic Claude format (ClaudeMessageParam[]) Output methods added/renamed: - getChatMessage() - returns OpenAI chat format (renamed from getMessage) - getClaudeMessage() - returns Anthropic Claude format (new) - getNewChatMessagesStream() - stream chat messages (renamed from getNewMessagesStream) Also includes: - New ClaudeMessage types mirroring Anthropic SDK types - Automatic format detection and conversion - convertToClaudeMessage() helper for response transformation - Updated examples demonstrating all input/output formats - E2E tests for Claude-style message handling BREAKING CHANGE: getMessage() renamed to getChatMessage() BREAKING CHANGE: getNewMessagesStream() renamed to getNewChatMessagesStream() 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
louisgv
reviewed
Dec 16, 2025
louisgv
reviewed
Dec 16, 2025
louisgv
reviewed
Dec 16, 2025
louisgv
reviewed
Dec 16, 2025
louisgv
reviewed
Dec 16, 2025
Contributor
louisgv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels a bit weird to me in that we're shoving Anthropic input shape into callModel. Shouldn't we be owning the callModel API shape (?)
Change return type from chat format (AssistantMessage | ToolResponseMessage) to responses format (ResponsesOutputMessage | OpenResponsesFunctionCallOutput). - Add buildResponsesMessageStream() for streaming ResponsesOutputMessage - Add extractResponsesMessageFromResponse() for extracting from response - Update tests to validate new ResponsesOutputMessage shape - Update example and documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
The getChatMessage method doesn't exist on ResponseWrapper. Use getResponse() + toChatMessage() helper instead. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
… into fix-types-and-anthropic-messages
Demonstrates multi-turn conversations using: - ClaudeMessageParam type for Claude-style message format - fromClaudeMessages() to convert to OpenResponses input format - toClaudeMessage() to convert responses back to Claude format 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
The toChatMessage function is exported from chat-compat.js, not sdk.js. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
The callModel function now accepts ClaudeMessageParam[] directly and automatically converts them to OpenResponses format using fromClaudeMessages(). This enables passing Claude-style messages without manual conversion: - ClaudeMessageParam[] with string content - ClaudeMessageParam[] with content blocks (text, tool_use, tool_result, image) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
… into fix-types-and-anthropic-messages
subtleGradient
requested changes
Dec 17, 2025
- Add auto-detection of Claude-style messages with content block arrays - Convert Claude content blocks (text, image) to OpenRouter format - Fixes validation errors when passing Claude MessageParam directly to callModel() - Resolves CI test failures for Claude-style messages with content blocks arrays
subtleGradient
approved these changes
Dec 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
ClaudeMessageParam[]) as input tocallModel()getClaudeMessage()output method returning Anthropic-compatible response formatgetMessage()→getChatMessage()andgetNewMessagesStream()→getNewChatMessagesStream()for clarityInput formats now supported:
Message[])ClaudeMessageParam[])New types added:
ClaudeMessage,ClaudeMessageParam,ClaudeContentBlock, and related types mirroring the Anthropic SDK